package cn.yza.Kotlin.test

import java.lang.StringBuilder

/**
@author Honglixi
@create 2022-05-29 20:47
 */
fun <T> Collection<T>.joinToString(
        separator: String = ", ",
        prefix: String = "",
        postfix: String = ""
): String {
    val result = StringBuilder(prefix)
    for ((index, element) in this.withIndex()) {
        if (index > 0) result.append(separator)
        result.append(element)
    }
    result.append(postfix)
    return result.toString()
}
fun main() {
    val list = listOf<Int>(1,2,3)
    println(list.joinToString(separator = ";", prefix = "(", postfix = ")"))
}